#ifndef _Switch_thread_H_
#define _Switch_thread_H_
#include "stdint.h"
typedef enum 
{
	SW_Control=0,
	SW_Response=1,
	SW_Heartbeat=2,
	SW_Heartbeat_Response=3
}Switch_Protocol_Type;

typedef enum
{
	ResPonse_step_success=0,
	Response_step_wait=1,
	ResPonse_step_overtime=2,
}Response_Step;
typedef enum 
{
	SW_ON=0,
	SW_OFF=1
}Switch_Status_Type;
typedef union{
	struct
	{
		uint8_t :6;
		uint8_t relay_out:1;
		uint8_t sw_in:1;
	};
}SW_Status;
/****************开关协议***************/
typedef struct
{
	uint8_t     type;       //包类型
	SW_Status   status ;    //状态
	uint32_t    id;         //网络ID
}Switch_Protocol;

typedef struct
{
	uint16_t time;             //当前时间
	uint16_t filter_time;      //滤波阈值时间
	uint8_t out_status;       //滤波器输出状态
	uint8_t in_last_status;   //上次输入状态
}Switch_Filter_t;

//开关重发控制
typedef struct
{
	uint32_t time;
	uint32_t wait_time;        //等待时间
	uint8_t  retry_number;     //重发次数
	uint8_t  response_step;    //响应的步骤
}Switch_Retry_t;

typedef struct
{
	uint8_t SW_IN_Status;
	uint8_t SW_IN_FB_Status;
	uint8_t SW_OUT_Status;
}Switch_Model_t;

void Lora_Switch_Recive(uint8_t *data,uint8_t len);
void Switch_thread_entry(void *paremeter);

uint8_t User_Get_Relay_status();
uint8_t User_Get_Sw_status();
#endif
